package com.dudsbury.database;
import java.util.ArrayList;

import org.joda.time.DateTime;



public class ObjectCreator {
	
	private Database database;
	
	public ObjectCreator(Database database) {
		this.database = database;
	}
	//DateTime(int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minuteOfHour)
	public ArrayList<Booking> bookingCreate() {
		
		String[][] query = database.returnQuery("select * from Booking"); 
		ArrayList<Booking> bookingList = new ArrayList<Booking>();
		
		for (int y = 0; y < query[0].length; y++) {
			Booking booking = new Booking();
			//System.out.println(query[3][y]);
			
			String hold[] = query[3][y].split("-");
			
			booking.setDate(new DateTime(Integer.valueOf(hold[0]),Integer.valueOf(hold[1]),Integer.valueOf(hold[2]),0,0));
			bookingList.add(booking);
			}
		return bookingList;
			
		}
	
	public String[] getRooms() {
		String[][] query = database.returnQuery("select * from Room");
		String[] roomList = new String[query[0].length];
		
		for (int y = 0; y < query[0].length; y++) {
			roomList[y] = query[1][y];
		}
		return roomList;
	}
	}


